﻿using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;


namespace mirror
{
    class Sprite
    {
        private Texture2D mTexture;
        private Vector2 mPos;
        private float mOrientation;
        private float mScale;
        private float mDepth;
        private float mRadius;

        private Rectangle mRectangle;

        private float mHeight;

        public Sprite()
        {
            mScale = 1.0f;
            mDepth = 1.0f;
            mRadius = 1.0f;
            mHeight = 1.0f;
            mPos = new Vector2(1600, 1200);

            mRectangle = new Rectangle(0, 0, 0, 0);
        }

        public Sprite(Texture2D texture)
        {
            mTexture = texture;
            mPos = new Vector2(1600, 1200);

            mRectangle = new Rectangle(0, (int)(mTexture.Height * (1 - mHeight)), mTexture.Width, mTexture.Height);
        }

        public void setRectangleHeight(float zHeight)
        {
            // use a value between 1.0f and 0.0f;
            mRectangle = new Rectangle(0, (int)(mTexture.Height * (1 - mHeight)), mTexture.Width, (int)(mTexture.Height * zHeight));
        }

        public void setHeight(float height) { mHeight = height; }

        public void setTexture(Texture2D texture)
        {
            mTexture = texture;
            mRectangle = new Rectangle(0, (int)(mTexture.Height * (1 - mHeight)), mTexture.Width, mTexture.Height);
        }

        public Texture2D getTexture() { return mTexture; }
        public void setRadius(float radius) { mRadius = radius; }
        public float getRadius() { return mRadius * mTexture.Height / 2.0f; }
        public float getActualRadius() { return mTexture.Height / 2.0f; }
        public void setScale(float scale) { mScale = scale; }
        public float getScale() { return mScale; }
        public void setDepth(float depth) { mDepth = depth; }
        public float getDepth() { return mDepth; }
        public Rectangle GetRectangle() { return mRectangle; }
        public float GetOrientation() { return mOrientation; }

        public void Update(Vector2 pPos, float pOrientation)
        {
            SetPos(pPos);
            mOrientation = pOrientation;
        }

        public void SetPos(Vector2 pPos)
        {
            mPos = pPos;
        }
        public Vector2 GetPos()
        {
            return mPos;
        }

        public void Draw()
        {
            SpriteManager.Instance.DrawMe(this);
        }

        public Vector2 GetTextureDimensions()
        {
            return new Vector2(mTexture.Width / 2, mTexture.Height / 2 - (1 - mHeight) * mTexture.Height);
        }
    }
}
